#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;


int main(){
	int m,n,ans=0x7fffffff+1;
	cin>>m>>n;
	n--;
	int a[n+1];
	for(int i=1;i<=n;i++)
		a[i] = 0x7fffffff+1;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			int l;
			cin>>l;
			a[j] = max(a[j],l);
		}
	}
	int dp[n+1];
	dp[0] = 0;
	for(int i=1;i<=n;i++){
		ans = max(ans,dp[i] = max(a[i],dp[i-1]+a[i]));
	}
//	for(int i=0;i<=n;i++)
//		cout<<dp[i]<<" ";
//	cout<<endl;
//	for(int i=0;i<=n;i++)
//		cout<<a[i]<<" ";
//	cout<<endl;
	cout<<ans;
	return 0;
}
